#light

namespace Demos.WshScripting
#r @"webtools.core.dll"

open System
open FSharp.WebTools
open Demos.WshScripting
(*-----------------------------------------------------------------------------------------------*)

[<ClientSide>]
type SampleClass = 

  [<ReflectedDefinition>]
  member this.Read () =
    let pn = Console.ReadLine()
    if (pn <> "") then Some(pn) else None
    
  [<ReflectedDefinition>]
  member this.Main () =
    Console.WriteLine("Enter an executable name:")
    match this.Read() with
    | Some name ->
        Console.WriteLine("Starting '" + name + "' ...")
        let proc = Shell.Current.Exec(name)
        while (proc.Status = 0) do
          Script.Sleep(100)
        Console.WriteLine
          ("Process completed with code: " + 
           proc.Status.ToString())
    | _ ->
        Console.WriteLine("No text entered!")
